package br.gov.ms.tce.cjur.helper;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class CriptografaMD5Helper {
	
	
	
	public static String criptografa(String senha ) {
		String senhaCriptografada = "";
		try {

			MessageDigest currentAlgorithm = MessageDigest.getInstance("MD5");

			currentAlgorithm.reset();
			currentAlgorithm.update(senha.getBytes());

			byte[] hash = currentAlgorithm.digest();
			for (int i = 0; i < hash.length; i++)
			{
				int v = hash[i] & 0xFF;
				if (v < 16) senhaCriptografada += "0";
				senhaCriptografada += Integer.toString(v, 16);

			}
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();			
		}
		return senhaCriptografada;
	}
	


}